;:poke56,128:clr
;:open2,8,2,"code,p,w
;:sys36864
	*= $8000
hui	=*
	;.opt o2
tmp	=2
tmp2	=4
vic	=$d000
cint	=65409
bank	=56576
page	=648
konf	=1
char	=$e000
tmp3	=247
calc	=$e9f0
farbram	=$ea24
farb	=$f3
bild	=$d1
return	=$aad7
stack	=$5000
bsout	=$ffd2
key	=198
get	=65508
sendnam	=$f3d5
setpar	=$ffba
setnam	=$ffbd
fa	=$ba
sa	=$b9
status	=$90
iecin	=$ffa5
axout	=$bdcd
talk	=$ffb4
sectalk	=$ff96
space	=$ab3f
clsfil	=$f642
untalk	=$ffab
listen	=$ffb1
seclist	=$ff93
unlist	=$ffae
iecout	=$ffa8
input	=$ffcf
irqvec	=788
oldirq	=$ea31
ioinit	=$fd15
picmem	=$a000
fram	=$d800
clrscr	=$e544
joystick	=56320
sprptr	=51192
sprmem	=51200
sel	=vic+21
zeile	=214
spalte	=211
setcr	=58732
shift	=653
clrx	=59903
keyrep	=650
col	=646
rand	=162
kbuf	=631
scr	=50176
endscr	=scr+960
saver	=$ffd8
ioflg	=157
loadr	=$ffd5
fam	=$400
gra	=$2000
open	=$ffc0
close	=$ffc3
clrchn	=$ffcc
chkout	=$ffc9
buffer	=$cf00
	jsr clrmem
	jmp losgehts
chartab	.byt 107,0,$78,$fc,$cf,$cf,$fc,$78,0
	.byt 126,0,0,224,$70,$18,$c,$c,6
	.byt 114,$3c,$7e,$66,$66,$7e,$3c,$18,$18
	.byt 127,6,$c,$c,$18,$70,224,0,0
	.byt 113,$18,$18,$db,$7e,$3c,$18,0,0
	.byt 118,-1,129,129,129,129,129,129,-1
	.byt 95,32,48,$18,$fc,$fc,$18,48,32
	.byt 108,48,48,48,$f0,$f0,48,48,48
	.byt 92,$18,$18,48,224,224,48,$18,$18
	.byt 104,48,48,48,48,48,48,48,48
	.byt 123,0,0,$3f,48,48,48,48,48
	.byt 124,48,48,48,48,48,$3f,0,0
	.byt 102,6,6,3,3,3,3,6,6
	.byt 120,0,0,$f0,$1c,$c,6,7,3
	.byt 98,3,7,6,$c,$1c,$f0,0,0
	.byt 121,$c0,$e0,$70,$30,$18,$1c,$e,6
	.byt 111,6,$e,$1c,$18,$30,$70,$e0,$c0
	.byt 117,$c0,$e0,$70,$f0,$f8,$1c,$e,6
	.byt 97,6,$e,$1c,$f8,$f0,$70,$e0,$c0
	.byt 115,$18,$18,$18,-1,-1,6,6,6
	.byt 105,6,6,6,-1,-1,$18,$18,$18
	.byt 106,$18,$18,48,48,0,0,0,0
	.byt 116,0,0,0,0,48,48,$18,$18
	.byt 78,$3c,$3f,$3f,$3f,$3c,$3c,$3c,0
	.byt 77,$3c,$3c,$fc,$fc,$fc,$3c,$3c,0
	.byt 83,$f,$3c,$3c,$f,0,$3c,$f,0
	.byt 68,$f0,$3c,0,$f0,$3c,$3c,$f0,0
	.byt 94,0,4,6,$3f,$3f,$36,$34,$30
	.byt 81,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0
	brk
bitt	=787	;keine zp-adr.
speed	=166
x	=249
y	=250
dir	=253
stpt	=12
edscr	=168
sphi	=13
hellart	=178
hellohn	=179
momspd	=180
odir	=254
sti	=6
wahl	=7
awahl	=8
mode	=169
foundz	=14
mx	=251
my	=252
me1	=181
me2	=182
sft	=170
oldrnd	=255
schonf	=171
worth	=143
use	=34
mask	=36
flg	=139
xk	=141
yk	=63
offx	=37
axk	=176
xtab	=1024
ytab	=xtab+8
fname	.byte "dcs/"
name	.byte "            "
bldtab	.byt 93,64,95,113,110,109,112,125,92,66,67,91,108
	.byt 115,105
adrtab	.word p93,p64,p95,p113,p110,p109,p112,p125,p92,p93,p64
	.word p91,p108,p115,p105
hell	.byt 6,11,12,15,1,15,12,11,-1
mark	.byt 114,107,113,95
leg	.byt 1,40,40,1
logtab	.byte "aoep"
plazun	.byt 21,21,21,23
plazre	.byt 37,37,36,38
symtab	.word tand,tor
logtyp	.byt 0,0,1,-1
tand	.byt 123,120,32,108,32,121,104,32,102,108,32,111
	.byt 124,98,32
tor	.byt 123,120,32,115,64,117,102,32,102,105,64,97
	.byt 124,98,32
abadr	.byt 0,1,2,40,41,42,80,81,82,120,121,122,160,161,162
menchr	.byte "xndketgf"
menmen	.word prgend,prgneu,catja,command,editor,extest
	.word setspeed,file
grbit	.byt 1,2,4,8,$10,$20,$40,$80,0
sevtab	.byt 80,0,16,27,8
mulh	.byt 0,1,2,3,5,6,7,8,10,11,12,13,15,16
	.byt 17,18,20,21,22,23,25,26,27,28,30,31
mull	.byt 0,$40,$80,$c0
filtab	.byte "_\x86\x85\x87"
filadr	.word menue,file1,file2,file3
title	.byte "\x93\x98\x12\x08\x8e\x19) \x19&\x1d  \x92\x19\x04 digi - construktion - set v1.2"
	.byte "\x19\x04 \x12  \x92\x19\x04\x1d\x19\x1e\xa3\x19\x04\x1d\x12  \x92\x19\x06 (c) nikolaus heusler"
	.byte "  4.91\x19\x06 \x12  \x19&\x1d  \x92\x19\x09 ein  N"
	.byte "MSDSD programm\x19\x09 \x12  \x19&\x1d\x19) \x1a\x9a\x03"
mentxt	.byte "\x12\x05\x19) \x19&\x1d  \x92\x19\x0e hauptmenue\x19\x0e\x1d\x12  \x19&\x1d  \x1d e"
	.byte " \x92 - editor\x19\x08\x1d\x12 t \x92 - austesten\x12\x1d\x1d  \x19&\x1d  \x1d x \x92 -"
	.byte " programmende\x1d\x1d\x12 n \x92 - neustart   \x12  \x19&\x1d"
	.byte "  \x1d d \x92 - directory\x19\x05\x1d\x12 k \x92 - kommando\x1d\x1d\x1d\x12  \x19&\x1d"
	.byte "  \x1d g \x92 - geschwind.\x19\x04\x1d\x12 f \x92 - file\x19\x07\x1d\x12  \x19&\x1d"
	.byte "\x19) \x03"
bye	.byte "\x1a\x19\x10}\x1d\x11\x11servus\x11\x19\x06\x9d\x19\x06\xa3\x1a\x1a\x19\x09\x1dneustart:  sys 32771\x1a\x1a\x03"
keyy	.byte "\x1a\x90(bitte\x05 taste\x90 druecken)\x03"
dirnam	.byte "$0"
warnt	.byte "\x1a\x13\x19\x17\x11w a r n u n g !  datenverlust !!!\x03"
usurt	.byte "\x17\x91"
surt	.byte "\x1asind sie sicher ? [j/n]\x03"
editt	.byte "\x1a\x93\x19\x05\x11\x19\x09\x1d...editor coming up..."
	.byte "\x1a\x11\x19\x09\x1djoystick bitte port #2"
	.byte "\x1a\x11\x19\x09\x1d\x12 f1 \x92 - hilfsbildschirm\x1a\x19\x09\x1d\x11\x03"
help	.byte "\x13\x1a\x93\x9a\x19\x07 hilfsbildschirm\x1a"
	.byte "\x05\x1a\x12 m \x92 - marker\x19\x07 \x12 x \x92 - menue\x1a"
	.byte "\x1a\x12 1-9 \x92 - seite\x19\x06 \x12 clr \x92 - loeschen\x1a"
	.byte "\x1a\x12 v \x92 - verteiler\x19\x04 \x12 shift \x92 - moduswahl\x1a\x1a"
	.byte "\x1a\x12 a \x92 - und\x19\x0a \x12 o \x92 - oder\x1a"
	.byte "\x1a\x12 e \x92 - ex-oder\x19\x06 \x12 p \x92 - puffer\x1a"
	.byte "\x1a   (mit \x12shift\x92: invertierend)\x1a\x03"
statt	.byte "\x17\x9b\x12seite \x05*\x9b modus \x05d**\x9b\x19\x16 \x03"
modt	.byt 151,146,140,133
chostxt	.byte "\x05\x11bitte waehlen sie eine seite !"
	.byte "\x9b\x1a\x1a\x19\x0a 1 2 3 4 5 6 7 8 9 ~menue\x1a"
	.byte "\x1a\x1a\x05waehlen mit \x12crsr\x92, \x12home\x92 u. \x12return\x03"
moegl	.byte "\x05\x11bitte waehlen sie eine betriebsart !\x1a\x1a\x9b"
	.byte "  \x12 f1 \x92  konfiguration eingeben\x1a\x1a"
	.byte "  \x12 f3 \x92  alles durchprobieren\x1a\x1a"
	.byte "  \x12 f5 \x92  zurueck\x03"
setin	.byte "\x17\x05\x120,1\x92 - zustand  \x12stop\x92 - ende  \x12+\x92 - weiter\x03"
wodenn	.byte "\x17\x96??? kein marker gefunden (taste)\x03"
nomal	.byte "\x17\x05nochmal ? [j/n]\x03"
toomuch	.byte "\x17\x96??? zu viele marker [max.8] (taste)\x03"
prot	.byte "\x17\x05\x12 w \x92 - eiter, \x12 a \x92 - bbruch\x03"
spdtxt	.byte "\x05\x11bitte stellen sie die geschwindigkeit\x1a"
	.byte "ein ! (\x12crsr\x92, \x12return\x92)\x1a"
	.byte "\x19(\xa4\x1a\x19(\xa3\x03"
filet	.byte "\x05\x11file - menue: bitte waehlen:\x1a"
	.byte "\x1a\x1d\x12 f1 \x92 - bild laden\x1a"
	.byte "\x1a\x1d\x12 f3 \x92 - bild speichern\x1a"
	.byte "\x1a\x1d\x12 f5 \x92 - bild drucken (mps 801)\x1a"
	.byte "\x1a\x1d\x12 _\xc0 \x92 - zurueck\x03"
file1t	.byte "\x05\x92\x17dieses bild speichern ? [j/n]\x03"
filent	.byte "\x05\x11filename ? \x03"
file2t	.byte "\x05\x92\x17in dieses bild laden ? [j/n]\x03"
file3t	.byte "\x05\x92\x17dieses bild drucken ? [j/n]\x03"
init	jsr cint
	lda #6
	sta vic+32
	sta vic+33
	lda #148
	sta bank
	lda #128
	sta keyrep
	lda #196
	sta page
	lda #24
	sta vic+24
	ldx #8
	sei
	lda #51
	sta konf
	ldy #0
	sty tmp
	sty tmp2
	lda #>vic
	sta tmp+1
	lda #>char
	sta tmp2+1
copych	lda (tmp),y
	sta (tmp2),y
	dey
	bne copych
	inc tmp+1
	inc tmp2+1
	dex
	bne copych
	lda #55
	sta konf
	cli
	lda #<chartab
	ldy #>chartab
	sta tmp
	sty tmp+1
s1	ldy #0
	sty stpt
	lda (tmp),y
	beq feed
	sty tmp2+1
	asl
	rol tmp2+1
	asl
	rol tmp2+1
	asl
	rol tmp2+1
	sta tmp2
	sta tmp3
	lda #>char
	clc
	adc tmp2+1
	sta tmp2+1
	clc
	adc #4
	sta tmp3+1
	ldy #7
	inc tmp
	bne s3
	inc tmp+1
s3	lda (tmp),y
	sta (tmp2),y
	eor #-1
	sta (tmp3),y
	dey
	bpl s3
	lda tmp
	clc
	adc #8
	sta tmp
	lda tmp+1
	adc #0
	sta tmp+1
	bne s1
feed	sta ioflg
	lda #<neuirq
	ldy #>neuirq
	sei
	sta irqvec
	sty irqvec+1
	cli
	lda #8
	sta sprptr
	ldx #63
	lda #0
clrspr	sta sprmem,x
	dex
	bpl clrspr
	lda #-1
	sta sprmem
	sta sprmem+27
	lda #192
	sta sprmem+1
	sta sprmem+28
	ldx #7
	ldy #3
setsek	lda #128
	sta sprmem,y
	iny
	lsr
	sta sprmem,y
	iny
	iny
	dex
	bpl setsek
	rts
clrmem	ldx #36
	ldy #0
	sty tmp
	lda #>picmem
	sta tmp+1
	lda #32
cmem	sta (tmp),y
	dey
	bne cmem
	inc tmp+1
	dex
	bne cmem
	rts
calckxy	ldx y
	jsr calc
	lda x
	clc
	adc bild
	sta bild
	lda #0
	tay
	adc bild+1
	sta bild+1
	jmp farbram
strout0	jsr strout
	ldx #0
	stx key
	rts
setvic	sta bank
	stx vic+17
	rts
tost	ldx stpt
	sta stack,x
	inc stpt
stte	bne stok
	sec
	rts
stok	clc
	rts
frst	dec stpt
	ldx stpt
	lda stack,x
	cpx #-1
	jmp stte
wait	ldx speed
	beq fast
	ldy #-1
slow	dey
	bne slow
	dex
	bne slow
fast	rts
pause	ldy #0
pse	dey
	bne pse
	dex
	bne pse
	rts
apres	ldy #0
	lda bitt
	sta (farb),y
	rts
titout	lda #<title
	ldy #>title
strout	tax
	lda tmp
	pha
	lda tmp+1
	pha
	stx tmp
	sty tmp+1
st	ldy #0
	lda (tmp),y
	beq tfin
	cmp #"\x03"
	beq tfin
	cmp #"\x1a"
	bne nocr
	lda #13
nocr	cmp #"\x19"
	beq repeat
	cmp #"\x17"
	beq unters
	jsr bsout
scont	inc tmp
	bne st
	inc tmp+1
	bne st
repeat	iny
	lda (tmp),y
	tax
	iny
	lda (tmp),y
rep	jsr bsout
	dex
	bne rep
	clc
	lda #3
	adc tmp
	sta tmp
	lda #0
	adc tmp+1
	sta 1+tmp
	bne st
tfin	pla
	sta tmp+1
	pla
	sta tmp
	rts
unters	ldx #24
	stx zeile
	jsr clrx
	lda #0
	sta spalte
	jsr setcr
	jmp scont
getkey	lda #<keyy
	ldy #>keyy
gkey	jsr strout
gky	lda #0
	sta key
gk	lda key
	beq gk
	dec key
	rts
neuirq	jsr spirq
	jmp oldirq
spirq	lda sel
	bne span
	rts
span	lda #0
	sta sphi
	lda x
	asl
	rol sphi
	asl
	rol sphi
	asl
	rol sphi
	clc
	adc #23
	sta vic
	lda sphi
	adc #0
	sta vic+16
	lda y
	asl
	asl
	asl
	adc #49
	sta vic+1
	dec hellohn
	beq gehtso
	rts
gehtso	lda #4
	sta hellohn
	inc hellart
	ldx hellart
	lda hell,x
	bpl pluss
	ldx #0
	stx hellart
	lda hell
pluss	sta vic+39
	lda edscr
	clc
	adc #177
	sta $c000+1990
	lda shift
	and #1
	asl
	tax
	ldy #1
showmod	lda modt,x
	sta $c000+1999,y
	inx
	dey
	bpl showmod
	rts
adra	ldy #0
	sty tmp
	sty tmp2
	asl
	asl
	clc
	adc #>picmem
	sta tmp+1
	lda page
	sta tmp2+1
	ldx #4
	rts
holscr	jsr adra
	jsr ram
hollp	lda (tmp),y
	sta (tmp2),y
	dey
	bne hollp
	inc tmp+1
	inc tmp2+1
	dex
	bne hollp
	jsr rom
	jmp colin
ram	lda #48
	sei
	sta konf
	rts
rom	lda #55
	sta konf
	cli
	rts
colin	ldy #0
	sty tmp
	lda #>fram
	sta tmp+1
	ldx #4
	lda #12
clin	sta (tmp),y
	dey
	bne clin
	inc tmp+1
	dex
	bne clin
	rts
putscr	pha
	sei
	ldx #24
	jsr clrx
	pla
	jsr adra
putlp	lda (tmp2),y
	sta (tmp),y
	dey
	bne putlp
	inc tmp+1
	inc tmp2+1
	dex
	bne putlp
	cli
	rts
choose	jsr titout
	lda #<chostxt
	ldy #>chostxt
	jsr strout
	lda #10
	sta awahl
lhome	lda edscr
	sta wahl
anz	ldx #14
	jsr calc
	jsr farbram
	lda awahl
	asl
	clc
	adc #10
	tay
	lda #32
	sta (bild),y
	lda wahl
	asl
	clc
	adc #10
	tay
	lda #0
	sta (farb),y
	lda #30
	sta (bild),y
	lda wahl
	sta awahl
getlr	jsr get
	cmp #13
	beq crlf
	cmp #"\x11"
	beq left
	cmp #"\x9d"
	beq left
	cmp #"\x1d"
	beq right
	cmp #"\x13"
	beq lhome
	bne getlr
crlf	lda wahl
	rts
left	ldx wahl
	beq getlr
	dec wahl
	bpl anz
right	ldx wahl
	cpx #9
	bcs getlr
	inc wahl
	bne anz
testueberh	ldx #4
	lda page
	sta tmp+1
	lda #0
	sta tmp
	sta foundz
suche	ldy #0
	lda (tmp),y
	cmp #107
	beq h107
	cmp #114
	beq h114
goons	inc tmp
	bne suche
	inc tmp+1
	dex
	bne suche
	lda foundz
	bne daiswas
	lda #<wodenn
	ldy #>wodenn
	jsr strout
	jmp gky
daiswas	rts
h114	iny
	.byt $2c
h107	ldy #40
awert	lda (tmp),y
	cmp #118
	bne goons
	inc foundz
	jmp goons
editor	lda #<editt
	ldy #>editt
	jsr strout
	lda #<keyy+1
	ldy #>keyy+1
	jsr gkey
	jsr clrscr
	lda edscr
	jsr holscr
	ldx #0
	stx key
	stx x
	stx y
	inx
	stx sel
	lda #100
	sta momspd
neuf	lda #<statt
	ldy #>statt
	jsr strout
	lda #160
	sta 51175
	lda col
	sta 56295
eded	jsr calckxy
	lda dir
	sta odir
	lda key
	beq qjoyan
	jsr get
	cmp #"x"
	bne edgoon
	lda edscr
	jsr putscr
	dec sel
	jmp menue
qjoyan	jmp joyan
edgoon	cmp #"\x85"
	bne nof1
	lda edscr
	jsr putscr
	dec sel
	lda #<help
	ldy #>help
	jsr strout
	jsr getkey
	inc sel
	lda edscr
	jsr holscr
	jmp neuf
nof1	cmp #"m"
	bne nom
	ldx dir
	ldy leg,x
	cpy #1
	beq rec
	lda y
	cmp #23
	bcs eded
	bcc setmrk
rec	lda x
	cmp #39
	bcs eded
setmrk	lda #118
	sta (bild),y
	lda mark,x
	ldy #0
	sta (bild),y
	beq eded
nom	cmp #"1"
	bcc er
	cmp #"9"+1
	bcs er
	pha
	lda edscr
	jsr putscr
	pla
	sec
	sbc #"1"
	sta edscr
	jsr holscr
	jmp neuf
er	cmp #"\x93"
	bne noclr
	dec sel
	lda #<usurt
	ldy #>usurt
	jsr strout
	jsr gsure
	bcc spinner
	jsr clrscr
spinner	inc sel
	jmp neuf
noclr	cmp #"v"
	bne nov
	lda dir
	cmp #3
	bne qeded
	lda y
	beq qeded
	cmp #23
	bcs qeded
	ldy #0
	lda #92
	sta (bild),y
	inc y
	dec dir
qeded	jmp eded
nov	ldx #3
	and #127
suchlog	cmp logtab,x
	beq fundlog
	dex
	bpl suchlog
	bmi qeded
fundlog	lda y
	beq qeded
	cmp plazun,x
	bcs qeded
	lda x
	jsr hoeh
	cmp plazre,x
	bcs qeded
	lda dir
	cmp #3
	bne qeded
	jsr putlog
	jmp eded
joyan	lda joystick
	and #15
	sta sti
	cmp #15
	bne joyakt
	lda #100
	sta momspd
	jmp eded
joyakt	and #1
	bne jon1
	jsr ric1
	ldy y
	beq jon1
	dec y
jon1	lda sti
	and #2
	bne jon2
	jsr ric2
	ldy y
	cpy #23
	bcs jon2
	inc y
jon2	lda sti
	and #4
	bne jon4
	jsr ric4
	ldy x
	beq jon4
	dec x
jon4	lda sti
	and #8
	bne jon8
	jsr ric8
	ldy x
	cpy #39
	bcs jon8
	inc x
jon8	ldx momspd
	jsr pause
	lda momspd
	cmp #25
	bcc endfast
	sec
	sbc #2
	sta momspd
endfast	jsr setdel
	jmp eded
ric1	lda #0
	sta dir
	cmp odir
	bne wec0
ct1	ldy #0
	lda (bild),y
	cmp #64
	beq kruz
	cmp #32
	beq wec02
nox	rts
setchr	pha
	lda joystick
	and #16
	beq naalso
	pla
	rts
naalso	pla
	ldy #0
	sta (bild),y
	rts
wec0	ldx odir
	dex
	beq wec01
	dex
	beq wec02
	lda #125
	.byt $2c
wec01	lda #109
	.byt $2c
wec12	lda #125
	.byt $2c
wec02	lda #93
	.byt $2c
wec10	lda #110
	.byt $2c
sc64	lda #64
	.byt $2c
wec21	lda #112
	.byt $2c
kruz	lda #91
	jmp setchr
ric4	lda #1
	sta dir
	cmp odir
	bne wec1
ct2	ldy #0
	lda (bild),y
	cmp #93
	beq kruz
	cmp #32
	bne nox
	beq sc64
wec1	ldx odir
	beq wec10
	dex
	dex
	beq wec12
	bne sc64
ric2	lda #2
	sta dir
	cmp odir
	beq ct1
	ldx odir
	beq wec02
	dex
	beq wec21
	bne wec10
ric8	lda #3
	sta dir
	cmp odir
	beq ct2
	ldx odir
	beq wec21
	dex
	beq sc64
	bne wec01
setdel	lda shift
	and #1
	bne aechs
	rts
aechs	lda joystick
	and #16
	bne eee
	tay
	lda #32
	sta (bild),y
eee	rts
putlog	lda bild
	sec
	sbc #40
	sta bild
	lda bild+1
	sbc #0
	sta bild+1
	lda logtyp,x
	beq andor
	bpl exor
	ldy #0
	lda #123
	sta (bild),y
	iny
	lda #126
	sta (bild),y
	ldy #40
	lda #108
	sta (bild),y
	lda #102
	iny
	sta (bild),y
	ldy #80
	lda #124
	sta (bild),y
	lda #127
	iny
	sta (bild),y
	inc x
	inc x
	lda sft
	beq puffset
	ldy #42
invset	inc x
	lda #107
	sta (bild),y
puffset	rts
andor	txa
	asl
	tax
	lda symtab,x
	sta holadr+1
	lda symtab+1,x
	sta holadr+2
	ldx #0
holadr	lda !0,x
	ldy abadr,x
	sta (bild),y
	inx
	cpx #14
	bcc holadr
	inc x
	inc x
	inc x
	inc y
	lda sft
	beq puffset
	ldy #83
	bne invset
exor	ldy #0
	lda #116
	sta (bild),y
	iny
	lda #123
	sta (bild),y
	lda #120
	iny
	sta (bild),y
	ldy #40
	lda #115
	sta (bild),y
	iny
	sta (bild),y
	lda #64
	iny
	sta (bild),y
	lda #117
	iny
	sta (bild),y
	ldy #80
	lda #103
	sta (bild),y
	iny
	lda #102
	sta (bild),y
	iny
	iny
	sta (bild),y
	ldy #120
	lda #105
	sta (bild),y
	iny
	sta (bild),y
	iny
	lda #64
	sta (bild),y
	iny
	lda #97
	sta (bild),y
	ldy #160
	lda #106
	sta (bild),y
	iny
	lda #124
	sta (bild),y
	iny
	lda #98
	sta (bild),y
	inc x
	inc x
	inc x
	inc x
	inc y
	lda sft
	beq eorset
	ldy #84
	jmp invset
hoeh	tay
	lda shift
	and #1
	sta sft
	beq nosft
	iny
nosft	tya
eorset	rts
losgehts	jsr init
menue	jsr titout
	lda #<mentxt
	ldy #>mentxt
	jsr strout0
getmen	jsr get
	beq getmen
	ldx #menmen-menchr-1
sucmen	cmp menchr,x
	beq funmen
	dex
	bpl sucmen
	bmi getmen
funmen	txa
	asl
	tax
	lda menmen,x
	sta tmp
	lda menmen+1,x
	sta tmp+1
	jmp (tmp)
prgend	sei
	jsr ioinit
	lda #4
	sta page
	lda #151
	sta bank
	jsr cint
	lda #<bye
	ldy #>bye
	jmp strout
prgneu	lda #<warnt
	ldy #>warnt
	jsr strout
	jsr getsure
	bcc uff
	jmp hui
uff	jmp menue
getsure	lda #<surt
	ldy #>surt
	jsr strout
gsure	lda #0
	sta key
getjn	jsr get
	cmp #"j"
	beq ja
	cmp #"n"
	bne getjn
	clc
ja	rts
command	jsr titout
	lda #">"
	jsr bsout
	lda #8
	sta fa
	jsr listen
	lda #$6f
	sta sa
	jsr seclist
cmdout	jsr input
	cmp #13
	beq endcmd
	jsr iecout
	jmp cmdout
endcmd	jsr unlist
	jsr return
	lda fa
	jsr talk
	lda sa
	jsr sectalk
errin	jsr iecin
	jsr bsout
	cmp #13
	bne errin
	jsr untalk
	jmp dl5
catja	jsr titout
	lda #2
	ldx #<dirnam
	ldy #>dirnam
	jsr setnam
	ldx #8
	ldy #$60
	jsr setpar
	jsr sendnam
	lda fa
	jsr talk
	lda sa
	jsr sectalk
	lda #0
	sta status
	ldy #3
dl1	sty tmp
	jsr iecin
	sta tmp+1
	ldy status
	bne dl4
	jsr iecin
	ldy status
	bne dl4
	ldy tmp
	dey
	bne dl1
	ldx tmp+1
	jsr axout
	jsr space
dl3	jsr iecin
	ldx status
	bne dl4
	tax
	beq dl2
	jsr bsout
	bcc dl3
dl2	jsr return
	ldy #2
	bne dl1
dl4	jsr clsfil
dl5	jsr getkey
	jmp menue
setspeed	jsr titout
	lda #<spdtxt
	ldy #>spdtxt
	jsr strout
	lda speed
	eor #-1
	sta speed
	jsr anzg
getchsp	jsr get
	cmp #13
	beq sat
	cmp #"\x1d"
	beq ink
	cmp #"\x11"
	beq dek
	cmp #"\x9d"
	bne getchsp
dek	lda speed
	cmp #4
	bcs sub4
	lda #4
sub4	sec
	sbc #4
sspp	sta speed
	jsr anzg
	jmp getchsp
sat	lda speed
	eor #-1
	sta speed
	jmp menue
ink	lda speed
	cmp #252
	bcc add4
	lda #251
add4	clc
	adc #4
	bne sspp
anzg	pha
	ldx #14
	jsr calc
	pla
	lsr
	lsr
	lsr
	php
	clc
	ldy #4
	tax
	lda #160
anzl1	dex
	bmi rest1
	sta (bild),y
	iny
	bne anzl1
rest1	plp
	bcc nocyy
	lda #81
	.byt $2c
nocyy	lda #32
	sta (bild),y
	rts
goxy	jsr calckxy
	lda (bild),y
	cmp #107
	beq l10
	cmp #114
	bne exit
	lda #2
	ldy #1
	bne satpar
l10	lda #3
	ldy #40
satpar	sta dir
	lda (bild),y
	cmp #118
	bne norandom
	jsr random
norandom	and #1
	sta bitt
qqrun	jsr run
	lda stpt
	beq exit
	jsr frst
	bcs exit
	sta bitt
	jsr frst
	bcs exit
	sta dir
	jsr frst
	bcs exit
	sta y
	jsr frst
	bcs exit
	sta x
	jmp qqrun
exit	rts
run	jsr calckxy
	lda bitt
	sta (farb),y
	ldx dir
	beq sp0
	dex
	beq sp1
	dex
	beq sp2
	inc x
	bne spx
sp2	inc y
	bne spx
sp1	dec x
	jmp spx
sp0	dec y
spx	lda x
	bpl xok1
	lda #0
	sta x
xok1	cmp #40
	bcc xok2
	lda #39
	sta x
xok2	lda y
	bpl yok1
	lda #0
	sta y
yok1	cmp #25
	bcc yok2
	lda #24
	sta y
yok2	jsr calckxy
	lda (bild),y
	ldx #adrtab-bldtab-1
suchobj	cmp bldtab,x
	beq fundobj
	dex
	bpl suchobj
	rts
fundobj	txa
	asl
	tax
	lda adrtab,x
	sta goto+1
	lda adrtab+1,x
	sta goto+2
goto	jsr 0
	bcs exit
	jsr wait
	jmp run
random	sty me1
	lda #"0"
	ldx #0
	ldy #0
rnd	sty me2
	ldy me1
	eor #1
	sta (bild),y
	ldy me2
	dey
	bne rnd
	dex
	bne rnd
	ldy me1
	jsr mrand
	and #1
	clc
	adc #"0"
	sta (bild),y
	rts
mrand	lda oldrnd
	eor rand
	asl
	adc #0
	eor #-1
	sbc 53266
	adc oldrnd
	eor #123
	eor 53266
	sbc rand
	sta oldrnd
	rts
p64	lda dir
awdir	and #1
	bne cllc
errd	sec
	rts
p93	lda dir
	eor #1
	jmp awdir
p113	ldy #40
	.byt $2c
p95	ldy #1
	lda bitt
	pha
	ora #"0"
	sta (bild),y
	pla
	ldy #0
	sta (farb),y
	sec
p91	rts
p110	lda dir
	beq ok110
	cmp #3
	bne errd
ok110	eor #1
	bne sdir
p109	lda dir
	cmp #1
	beq ok109
	cmp #2
	bne errd
ok109	eor #1
sdir	sta dir
cllc	clc
	rts
p112	lda dir
	beq ok112
	cmp #1
	bne errd
ok112	eor #3
	bne sdir
p125	lda dir
	cmp #2
	beq ok125
	cmp #3
	bne errd
ok125	eor #3
	jmp sdir
p92	lda dir
	cmp #3
	bne errd
	lda x
	jsr tost
	bcs ex
	lda y
	jsr tost
	bcs ex
	lda #2
	jsr tost
	bcs ex
	lda bitt
	jsr tost
	bcs ex
	lda #0
	beq sdir
ex	rts
p108	ldy #1
	lda (bild),y
	cmp #102
	bne aand
	jsr apres
	inc x
	jsr calckxy
	ldy #1
	lda (bild),y
	cmp #107
	bne puffer
	lda bitt
	eor #1
	sta bitt
	sta (farb),y
	inc x
puffer	clc
	rts
aand	jsr apres
	ldy #40
	lda (bild),y
	cmp #124
	beq aunten
	lda #$2d
dubob	sta poke
	ldy #80
	lda (farb),y
	tax
	lda #43
	pha
	txa
	inc y
andlp	and #15
	cmp #2
	bcc poke
	pla
	rts
poke	and bitt
andfort	sta bitt
	inc x
	inc x
	pla
	tay
	lda (bild),y
	cmp #107
	bne eand
	lda bitt
	eor #1
	sta bitt
	inc x
eand	clc
	rts
aunten	lda #$2d
dubun	sta poke
	lda farb
	sec
	sbc #80
	sta farb
	lda farb+1
	sbc #0
	sta farb+1
	ldy #0
	lda (farb),y
	tax
	lda bild
	sec
	sbc #37
	sta bild
	lda bild+1
	sbc #0
	sta bild+1
	lda #0
	pha
	txa
	dec y
	jmp andlp
p115	jsr apres
	iny
	sta (farb),y
	ldy #40
	lda (bild),y
	cmp #102
	bne xorob
	lda #13
	bne dubob
p105	jsr apres
	iny
	sta (farb),y
	lda bild
	sec
	sbc #40
	sta bild
	lda bild+1
	sbc #0
	sta bild+1
	ldy #0
	lda (bild),y
	cmp #102
	bne xorun
	jsr calckxy
	lda #13
	bne dubun
xorob	ldy #80
	lda (farb),y
	tax
	lda #44
	pha
	txa
	inc y
xorlp	and #$f
	cmp #2
	bcc xrok
	pla
	rts
xrok	eor bitt
	inc x
	jmp andfort
xorun	jsr calckxy
	lda farb
	sec
	sbc #80
	sta farb
	lda farb+1
	sbc #0
	sta farb+1
	ldy #0
	lda (farb),y
	tax
	lda bild
	sec
	sbc #36
	sta bild
	lda bild+1
	sbc #0
	sta bild+1
	lda #0
	pha
	txa
	dec y
	jmp xorlp
extest	jsr choose
	cmp #9
	bcc nomen
	jmp menue
qauto	jmp auto
nomen	jsr holscr
	ldx #23
	stx zeile
	jsr setcr
	jsr getkey
	jsr titout
	lda #<moegl
	ldy #>moegl
	jsr strout0
getmgl	jsr get
	cmp #"\x87"
	beq extest
	cmp #"\x85"
	beq m1
	cmp #"\x86"
	bne getmgl
	lda #-1
	.byt $2c
m1	lda #0
	sta mode
	lda wahl
	jsr holscr
	jsr testueberh
	beq extest
	lda mode
	bne qauto
hand	lda #<setin
	ldy #>setin
	jsr strout
smkit	lda page
	sta tmp+1
	lda #0
	sta tmp
edsuch	ldy #0
	lda (tmp),y
	cmp #107
	beq m107
	cmp #114
	beq m114
follw	inc tmp
	bne edsuch
	inc tmp+1
	lda tmp+1
	cmp #200
	bcc edsuch
	bcs smkit
m114	iny
	.byt $2c
m107	ldy #40
	lda (tmp),y
	cmp #118
	beq jja
	cmp #"1"
	beq jja
	cmp #"0"
	bne follw
jja	tya
	clc
	adc tmp
	sta tmp2
	pha
	lda tmp+1
	adc #0
	sta tmp2+1
	sta bild+1
	pla
	sta bild
	jsr farbram
	ldy #0
	lda #1
	sta (farb),y
geteded	jsr get
	cmp #"+"
	beq qfollw
	cmp #"\x03"
	beq edfin
	cmp #"1"
	beq mansch
	cmp #"0"
	bne geteded
mansch	ldy #0
	sta (tmp2),y
	beq geteded
qfollw	ldy #0
	lda #12
	sta (farb),y
	jmp follw
edfin	ldy #0
	lda #12
	sta (farb),y
	jmp exec
auto	lda foundz
	cmp #9
	bcc kl9
	lda #<toomuch
	ldy #>toomuch
	jsr strout
o	jsr gky
	jmp extest
kl9	lda #0
	sta x
	sta y
	sta schonf
ausuch	jsr calckxy
	lda (bild),y
	cmp #107
	beq a107
	cmp #114
	beq a114
auoll	inc x
	lda x
	cmp #40
	bcc ausuch
	lda #0
	sta x
	inc y
	bne ausuch
a114	iny
	.byt $2c
a107	ldy #40
	lda (bild),y
	cmp #118
	bne auoll
	ldx schonf
	inc schonf
	cpy #40
	beq down
	lda x
	clc
	adc #1
	sta xtab,x
	lda y
	sta ytab,x
	jmp augoon
down	lda x
	sta xtab,x
	lda y
	clc
	adc #1
	sta ytab,x
augoon	lda schonf
	cmp foundz
	bcc auoll
nulle	lda #0
	sta worth
probloop	lda #0
	sta schonf
prolp2	ldx schonf
	cpx foundz
	beq readyset
	lda xtab,x
	sta x
	lda ytab,x
	sta y
	jsr calckxy
	ldx schonf
	lda grbit,x
	and worth
	beq aus
	lda #1
aus	ora #"0"
	sta (bild),y
	inc schonf
	bne prolp2
readyset	jsr exec
	lda #<prot
	ldy #>prot
	jsr strout0
getaw	jsr get
	cmp #"a"
	beq abbr
	cmp #"w"
	bne getaw
	jsr colin
	inc worth
	ldx foundz
	lda worth
	cmp grbit,x
	bcc probloop
	bcs nulle
abbr	jmp extest
exec	lda #0
	sta x
	sta y
exsuch	jsr calckxy
	lda (bild),y
	cmp #107
	beq e107
	cmp #114
	beq e114
exoll	inc x
	lda x
	cmp #40
	bcc exsuch
	lda #0
	sta x
	inc y
	lda y
	cmp #24
	bcc exsuch
	jmp fertig
e114	iny
	.byt $2c
e107	ldy #40
	lda (bild),y
	cmp #118
	beq jjja
	cmp #"1"
	beq jjja
	cmp #"0"
	bne exoll
jjja	lda x
	sta mx
	lda y
	sta my
	jsr goxy
	lda mx
	sta x
	lda my
	sta y
	jmp exoll
fertig	lda mode
	bne moden0
	lda #<nomal
	ldy #>nomal
	jsr strout
	jsr gsure
	bcs noal
	jmp extest
noal	lda wahl
	jsr holscr
	jmp hand
moden0	rts
file	jsr titout
	lda #<filet
	ldy #>filet
	jsr strout0
gfmen	jsr get
	beq gfmen
	ldx #3
nopf	cmp filtab,x
	beq filfnd
	dex
	bpl nopf
	bmi gfmen
filfnd	txa
	asl
	tax
	lda filadr,x
	sta gofil+1
	lda filadr+1,x
	sta gofil+2
gofil	jmp 0
file1	jsr choose
	cmp #9
	bcs file
	jsr holscr
	lda #<file1t
	ldy #>file1t
	jsr strout0
	jsr gsure
	bcc file1
	jsr filename
	bcs file
	lda wahl
	jsr holscr
	ldx #<endscr
	ldy #>endscr
	lda #<scr
	sta tmp
	lda #>scr
	sta tmp+1
	lda #tmp
	jsr saver
	jmp file
file2	jsr choose
	cmp #9
	bcs file
	jsr holscr
	lda #<file2t
	ldy #>file2t
	jsr strout0
	jsr gsure
	bcc file2
	jsr filename
	bcs file
	lda wahl
	jsr holscr
	ldx #<scr
	ldy #>scr
	lda #0
	jsr loadr
	lda wahl
	jsr putscr
	jmp file
filename	jsr titout
	lda #<filent
	ldy #>filent
	jsr strout
	lda #2
	sta key
	lda #34
	sta kbuf
	lda #20
	sta kbuf+1
	ldx #0
gname	jsr input
	cmp #13
	beq ncr
	sta name,x
	inx
	cpx #12
	bcc gname
ncr	cpx #0
	bne tats
	rts
tats	txa
	clc
	adc #4
	ldx #<fname
	ldy #>fname
	jsr setnam
	ldx #8
	ldy #1
	clc
	jmp setpar
file3	jsr choose
	cmp #9
	bcc go9
	jmp file
go9	jsr holscr
	lda #<file3t
	ldy #>file3t
	jsr strout0
	jsr gsure
	bcc file3
	ldx #24
	jsr clrx
	lda #151
	ldx #59
	jsr setvic
	lda #198
	ldy #0
	sty tmp
	ldx #>fam
	stx tmp+1
colein	sta (tmp),y
	dey
	bne colein
	inc tmp+1
	dex
	bne colein
	lda #0
	sta tmp
	sta tmp3
	lda #>scr
	sta tmp3+1
	lda #>gra
	sta tmp+1
	sei
	lda #48
	sta konf
tl3	lda #0
	sta tmp2
	ldy #>char
	sty tmp2+1
	tay
	lda (tmp3),y
	tax
	beq tl1
tl2	lda tmp2
	clc
	adc #8
	sta tmp2
	lda tmp2+1
	adc #0
	sta tmp2+1
	dex
	bne tl2
tl1	ldy #7
tl5	lda (tmp2),y
	sta (tmp),y
	dey
	bpl tl5
	lda tmp
	clc
	adc #8
	sta tmp
	lda tmp+1
	adc #0
	sta tmp+1
	inc tmp3
	bne tl8
	inc tmp3+1
	lda tmp3+1
	cmp #>scr+$400
	bcs tl0
tl8	jmp tl3
tl0	lda #55
	sta konf
	cli
	lda #0
	jsr setnam
	lda #4
	tax
	iny
	jsr setpar
	jsr open
	ldx #4
	jsr chkout
	lda #-1
	sta mask
	lda #7
	sta use
	lda #28
	sta flg
	lda #0
	sta me1
sev1	lda #40
	sta flg+1
	ldx #4
sev11	lda sevtab,x
	jsr bsout
	dex
	bpl sev11
	lda #0
	sta xk
	sta xk+1
sev2	lda me1
	sta yk
	lda #0
	sta use+1
sev3	lda xk
	ldx xk+1
	ldy yk
	jsr hposn
	ldy #0
	lda (tmp),y
	ldx use+1
	sta buffer,x
	inc yk
	inx
	stx use+1
	cpx use
	bne sev3
	lda #0
	ldy #7
sev4	ldx use
sev5	asl buffer,x
	rol
	dex
	bpl sev5
	and mask
	ora #$80
	jsr bsout
	dey
	bpl sev4
	lda xk
	clc
	adc #8
	sta xk
	bcc sev6
	inc xk+1
sev6	dec flg+1
	bne sev2
	jsr return
	lda me1
	clc
	adc #7
	sta me1
	dec flg
	beq sev81
sev8	jmp sev1
sev81	lda #4
	cmp use
	beq sev7
	sta  use
	lda #1
	sta flg
	lda #$f
	sta mask
	bne sev8
sev7	lda #15
	jsr bsout
	jsr clrchn
	lda #4
	jsr close
	lda #148
	ldx #27
	jsr setvic
	jmp file
hposn	sta axk
	stx axk+1
	tya
	lsr
	lsr
	lsr
	tax
	lda mulh,x
	sta tmp+1
	txa
	and #3
	tax
	lda mull,x
	sta tmp
	tya
	and #7
	clc
	adc tmp
	sta tmp
	lda axk
	and #$f8
	sta offx
	lda #>gra
	ora tmp+1
	sta tmp+1
	clc
	lda tmp
	adc offx
	sta tmp
	lda tmp+1
	adc axk+1
	sta tmp+1
	rts
